﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using Models;

namespace BLL
{
    public class BaojiaManager
    {
        private BaojiaService objBaojiaService = new BaojiaService();
        /// <summary>
        /// 判断报价表中是否有对应行
        /// 有：更新数据 没有：新增数据
        /// </summary>
        /// <param name="baojia"></param>
        /// <returns></returns>
        public void InsertBaojia(Baojia baojia)
        {
            int count = objBaojiaService.GetBaojia(baojia.WorkParentId);
            if(count==1)
            {
                objBaojiaService.UpdateBaojia(baojia);
            }
            else
            {
                objBaojiaService.InsertBaojia(baojia);
            }
        }
        /// <summary>
        /// 获取报价信息
        /// </summary>
        /// <param name="workParentId"></param>
        /// <returns></returns>
        public Baojia GetBaojiaInfo(int workParentId)
        {
            return objBaojiaService.GetBaojiaInfo(workParentId);
        }
    }
}
